Make from_string('') return []. This means that it is not necessary for our
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Mon, 12 Dec 2005 16:32:19 +0000 (16:32 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Mon, 12 Dec 2005 16:32:19 +0000 (16:32 +0000)
callers to special-case this value -- the [] is a valid sxp.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/sxp.py

index 88a81cdc8ad2457a18c235bc257278515fe29703..551a8d3ec222008030450610c98adae24386ad86 100644 (file)
@@ -696,13 +696,16 @@ def to_string(sxpr):
     io.close()
     return val
 
-def from_string(str):
+def from_string(s):
     """Create an sxpr by parsing a string.
 
-    str string
+    s string
     returns sxpr
     """
-    io = StringIO(str)
+    if s == '':
+        return []
+
+    io = StringIO(s)
     vals = parse(io)
     if vals is []:
         return None
@@ -710,13 +713,13 @@ def from_string(str):
         return vals[0]
     
 
-def all_from_string(str):
+def all_from_string(s):
     """Create an sxpr list by parsing a string.
 
-    str string
+    s string
     returns sxpr list
     """
-    io = StringIO(str)
+    io = StringIO(s)
     vals = parse(io)
     return vals